#include <pthread.h>
#include "type.h"

#define CREATE_TASK(index, task, params)                            		\
    do{                                                                 	\
        if( (task.task_function) && (task.status !=0) ){                	\
            printf("Create Task : %s\n",task.task_params.task_name);\
            task.task_params.task_args.argc = ((task_args_t*)params)->argc;    \
            task.task_params.task_args.argv = ((task_args_t*)params)->argv;    \
            task.task_params.task_id = index;                           	\
            task.status = pthread_create(&task.task_params.task_thread, 	\
                    NULL,                                               	\
                    (void*)task.task_function,                          	\
                    (void*)&task.task_params);                          	\
        }                                                               	\
    }while(0);

typedef struct {
    int argc;
    char** argv;
} task_args_t;

typedef struct {
    task_args_t task_args;
    int task_id;
    char task_name[10];
    pthread_t task_thread;
} task_params_t;

typedef struct {
    task_params_t task_params;
    int status;
    void (*task_function)(void *params);
} task_table_t;

void task_lan(void*);
void task_message(void *);

